}
#[cfg(test)]
+#[cfg(feature = "alloc")]
mod tests {
use super::{super::BLOCK_LEN, *};
use crate::test;
// This test exists largely as a canary for detecting if/when that type of
// problem spreads to other platforms.
#[test]
+ #[cfg(feature = "alloc")]
pub fn chacha20_tests() {
test::run(test_file!("chacha_tests.txt"), |section, test_case| {
assert_eq!(section, "");
}
#[cfg(test)]
+#[cfg(feature = "alloc")]
mod tests {
use super::*;
use crate::test;
unsafe impl PublicModulus for M {}
#[test]
+ #[cfg(feature = "alloc")]
fn test_elem_exp_consttime() {
test::run(
test_file!("bigint_elem_exp_consttime_tests.txt"),
// In the meantime, the function is tested indirectly via the RSA
// verification and signing tests.
#[test]
+ #[cfg(feature = "alloc")]
fn test_elem_mul() {
test::run(
test_file!("bigint_elem_mul_tests.txt"),
}
#[test]
+ #[cfg(feature = "alloc")]
fn test_elem_squared() {
test::run(
test_file!("bigint_elem_squared_tests.txt"),
}
#[test]
+ #[cfg(feature = "alloc")]
fn test_elem_reduced() {
test::run(
test_file!("bigint_elem_reduced_tests.txt"),
}
#[test]
+ #[cfg(feature = "alloc")]
fn test_elem_reduced_once() {
test::run(
test_file!("bigint_elem_reduced_once_tests.txt"),
}
#[cfg(test)]
+#[cfg(feature = "alloc")]
mod tests {
use super::digest_bytes_scalar;
use crate::{
};
#[cfg(test)]
+#[cfg(feature = "alloc")]
mod tests {
use crate::{signature, test};
};
#[cfg(test)]
+#[cfg(feature = "alloc")]
mod tests {
+ extern crate alloc;
use super::*;
use crate::test;
use alloc::vec::Vec;
}
#[test]
+ #[cfg(feature = "alloc")]
fn p256_elem_add_test() {
elem_add_test(
&p256::PUBLIC_SCALAR_OPS,
}
#[test]
+ #[cfg(feature = "alloc")]
fn p384_elem_add_test() {
elem_add_test(
&p384::PUBLIC_SCALAR_OPS,
);
}
+ #[cfg(feature = "alloc")]
fn elem_add_test(ops: &PublicScalarOps, test_file: test::File) {
test::run(test_file, |section, test_case| {
assert_eq!(section, "");
// the point arithmetic functions. Thus, we can't test it.
#[test]
+ #[cfg(feature = "alloc")]
fn p384_elem_sub_test() {
extern "C" {
fn GFp_p384_elem_sub(r: *mut Limb, a: *const Limb, b: *const Limb);
);
}
+ #[cfg(feature = "alloc")]
fn elem_sub_test(
ops: &CommonOps,
elem_sub: unsafe extern "C" fn(r: *mut Limb, a: *const Limb, b: *const Limb),
// into the point arithmetic functions. Thus, we can't test it.
#[test]
+ #[cfg(feature = "alloc")]
fn p384_elem_div_by_2_test() {
extern "C" {
fn GFp_p384_elem_div_by_2(r: *mut Limb, a: *const Limb);
);
}
+ #[cfg(feature = "alloc")]
fn elem_div_by_2_test(
ops: &CommonOps,
elem_div_by_2: unsafe extern "C" fn(r: *mut Limb, a: *const Limb),
// TODO: Add test vectors that test the range of values above `q`.
#[test]
+ #[cfg(feature = "alloc")]
fn p256_elem_neg_test() {
extern "C" {
fn GFp_nistz256_neg(r: *mut Limb, a: *const Limb);
}
#[test]
+ #[cfg(feature = "alloc")]
fn p384_elem_neg_test() {
extern "C" {
fn GFp_p384_elem_neg(r: *mut Limb, a: *const Limb);
);
}
+ #[cfg(feature = "alloc")]
fn elem_neg_test(
ops: &CommonOps,
elem_neg: unsafe extern "C" fn(r: *mut Limb, a: *const Limb),
}
#[test]
+ #[cfg(feature = "alloc")]
fn p256_elem_mul_test() {
elem_mul_test(&p256::COMMON_OPS, test_file!("ops/p256_elem_mul_tests.txt"));
}
#[test]
+ #[cfg(feature = "alloc")]
fn p384_elem_mul_test() {
elem_mul_test(&p384::COMMON_OPS, test_file!("ops/p384_elem_mul_tests.txt"));
}
+ #[cfg(feature = "alloc")]
fn elem_mul_test(ops: &CommonOps, test_file: test::File) {
test::run(test_file, |section, test_case| {
assert_eq!(section, "");
}
#[test]
+ #[cfg(feature = "alloc")]
fn p256_scalar_mul_test() {
scalar_mul_test(
&p256::SCALAR_OPS,
}
#[test]
+ #[cfg(feature = "alloc")]
fn p384_scalar_mul_test() {
scalar_mul_test(
&p384::SCALAR_OPS,
);
}
+ #[cfg(feature = "alloc")]
fn scalar_mul_test(ops: &ScalarOps, test_file: test::File) {
test::run(test_file, |section, test_case| {
assert_eq!(section, "");
}
#[test]
+ #[cfg(feature = "alloc")]
fn p256_scalar_square_test() {
extern "C" {
fn GFp_p256_scalar_sqr_rep_mont(r: *mut Limb, a: *const Limb, rep: Limb);
// XXX: There's no `p384_scalar_square_test()` because there's no dedicated
// `GFp_p384_scalar_sqr_rep_mont()`.
+ #[cfg(feature = "alloc")]
fn scalar_square_test(
ops: &ScalarOps,
sqr_rep: unsafe extern "C" fn(r: *mut Limb, a: *const Limb, rep: Limb),
}
#[test]
+ #[cfg(feature = "alloc")]
fn p256_point_sum_test() {
point_sum_test(
&p256::PRIVATE_KEY_OPS,
}
#[test]
+ #[cfg(feature = "alloc")]
fn p384_point_sum_test() {
point_sum_test(
&p384::PRIVATE_KEY_OPS,
);
}
+ #[cfg(feature = "alloc")]
fn point_sum_test(ops: &PrivateKeyOps, test_file: test::File) {
test::run(test_file, |section, test_case| {
assert_eq!(section, "");
// multiplication to use.
#[cfg(any(target_arch = "aarch64", target_arch = "x86", target_arch = "x86_64"))]
#[test]
+ #[cfg(feature = "alloc")]
fn p256_point_sum_mixed_test() {
extern "C" {
fn GFp_nistz256_point_add_affine(
// XXX: There is no `GFp_nistz384_point_add_affine()`.
#[cfg(any(target_arch = "aarch64", target_arch = "x86", target_arch = "x86_64"))]
+ #[cfg(feature = "alloc")]
fn point_sum_mixed_test(
ops: &PrivateKeyOps,
point_add_affine: unsafe extern "C" fn(
}
#[test]
+ #[cfg(feature = "alloc")]
fn p256_point_double_test() {
extern "C" {
fn GFp_nistz256_point_double(
}
#[test]
+ #[cfg(feature = "alloc")]
fn p384_point_double_test() {
extern "C" {
fn GFp_nistz384_point_double(
);
}
+ #[cfg(feature = "alloc")]
fn point_double_test(
ops: &PrivateKeyOps,
point_double: unsafe extern "C" fn(
}
#[test]
+ #[cfg(feature = "alloc")]
fn p256_point_mul_test() {
point_mul_tests(
&p256::PRIVATE_KEY_OPS,
}
#[test]
+ #[cfg(feature = "alloc")]
fn p384_point_mul_test() {
point_mul_tests(
&p384::PRIVATE_KEY_OPS,
);
}
+ #[cfg(feature = "alloc")]
fn point_mul_tests(ops: &PrivateKeyOps, test_file: test::File) {
test::run(test_file, |section, test_case| {
assert_eq!(section, "");
}
#[test]
+ #[cfg(feature = "alloc")]
fn p256_point_mul_serialized_test() {
point_mul_serialized_test(
&p256::PRIVATE_KEY_OPS,
);
}
+ #[cfg(feature = "alloc")]
fn point_mul_serialized_test(
priv_ops: &PrivateKeyOps,
pub_ops: &PublicKeyOps,
}
#[test]
+ #[cfg(feature = "alloc")]
fn p256_point_mul_base_test() {
point_mul_base_tests(
&p256::PRIVATE_KEY_OPS,
}
#[test]
+ #[cfg(feature = "alloc")]
fn p384_point_mul_base_test() {
point_mul_base_tests(
&p384::PRIVATE_KEY_OPS,
);
}
+ #[cfg(feature = "alloc")]
fn point_mul_base_tests(ops: &PrivateKeyOps, test_file: test::File) {
test::run(test_file, |section, test_case| {
assert_eq!(section, "");
}
}
+ #[cfg(feature = "alloc")]
fn consume_jacobian_point(
ops: &PrivateKeyOps,
test_case: &mut test::TestCase,
}
#[cfg(any(target_arch = "aarch64", target_arch = "x86", target_arch = "x86_64"))]
+ #[cfg(feature = "alloc")]
fn consume_affine_point(
ops: &PrivateKeyOps,
test_case: &mut test::TestCase,
p
}
+ #[cfg(feature = "alloc")]
fn consume_point_elem(ops: &CommonOps, limbs_out: &mut [Limb], elems: &[&str], i: usize) {
let bytes = test::from_hex(elems[i]).unwrap();
let bytes = untrusted::Input::from(&bytes);
Affine(Elem<R>, Elem<R>),
}
+ #[cfg(feature = "alloc")]
fn consume_point(ops: &PrivateKeyOps, test_case: &mut test::TestCase, name: &str) -> TestPoint {
fn consume_point_elem(ops: &CommonOps, elems: &[&str], i: usize) -> Elem<R> {
let bytes = test::from_hex(elems[i]).unwrap();
}
}
+ #[cfg(feature = "alloc")]
fn consume_elem(ops: &CommonOps, test_case: &mut test::TestCase, name: &str) -> Elem<R> {
let bytes = consume_padded_bytes(ops, test_case, name);
let bytes = untrusted::Input::from(&bytes);
}
}
+ #[cfg(feature = "alloc")]
fn consume_scalar(ops: &CommonOps, test_case: &mut test::TestCase, name: &str) -> Scalar {
let bytes = test_case.consume_bytes(name);
let bytes = untrusted::Input::from(&bytes);
scalar_parse_big_endian_variable(ops, AllowZero::Yes, bytes).unwrap()
}
+ #[cfg(feature = "alloc")]
fn consume_scalar_mont(
ops: &CommonOps,
test_case: &mut test::TestCase,
}
}
+ #[cfg(feature = "alloc")]
fn consume_padded_bytes(
ops: &CommonOps,
test_case: &mut test::TestCase,
use crate::test;
#[test]
+ #[cfg(feature = "alloc")]
fn parse_uncompressed_point_test() {
test::run(
test_file!("suite_b_public_key_tests.txt"),
#![forbid(unused_results)]
#![no_std]
-#[cfg(feature = "alloc")]
+#[cfg(any(feature = "alloc",test))]
extern crate alloc;
#[macro_use]
const MAX: Limb = LimbMask::True as Limb;
#[test]
+ #[cfg(feature = "alloc")]
fn test_limbs_are_even() {
static EVENS: &[&[Limb]] = &[
&[],
}
#[test]
+ #[cfg(feature = "alloc")]
fn test_limbs_equal_limb() {
for zero in ZEROES {
assert_eq!(limbs_equal_limb_constant_time(zero, 0), LimbMask::True);
}
#[test]
+ #[cfg(feature = "alloc")]
fn test_limbs_minimal_bits() {
const ALL_ONES: Limb = LimbMask::True as Limb;
static CASES: &[(&[Limb], usize)] = &[
use alloc::vec;
#[test]
+ #[cfg(feature = "alloc")]
fn test_pss_padding_verify() {
test::run(
test_file!("rsa_pss_padding_tests.txt"),
}
#[cfg(test)]
+#[cfg(feature = "alloc")]
mod tests {
use crate::{error, test};
wasm_bindgen_test_configure!(run_in_browser);
use core::ops::RangeFrom;
-use ring::{aead, error, test, test_file};
+use ring::{aead, error, test};
+
+#[cfg(feature = "alloc")]
+use ring::test_file;
#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
+#[cfg(feature = "alloc")]
fn aead_aes_gcm_128() {
test_aead(
&aead::AES_128_GCM,
#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
+#[cfg(feature = "alloc")]
fn aead_aes_gcm_256() {
test_aead(
&aead::AES_256_GCM,
target_arch = "x86"
))]
#[test]
+#[cfg(feature = "alloc")]
fn aead_chacha20_poly1305() {
test_aead(
&aead::CHACHA20_POLY1305,
);
}
+#[cfg(feature = "alloc")]
fn test_aead<Seal, Open>(
aead_alg: &'static aead::Algorithm,
seal: Seal,
))]
#[allow(clippy::range_plus_one)]
#[test]
+#[cfg(feature = "alloc")]
fn aead_chacha20_poly1305_openssh() {
// TODO: test_aead_key_sizes(...);
extern crate alloc;
-use ring::{agreement, error, rand, test, test_file};
+use ring::{agreement, error, rand, test};
+
+#[cfg(feature = "alloc")]
+use ring::test_file;
#[test]
fn agreement_traits() {
}
#[test]
+#[cfg(feature = "alloc")]
fn agreement_agree_ephemeral() {
let rng = rand::SystemRandom::new();
}
#[test]
+#[cfg(feature = "alloc")]
fn test_agreement_ecdh_x25519_rfc_iterated() {
let mut k = h("0900000000000000000000000000000000000000000000000000000000000000");
let mut u = k.clone();
)
}
+#[cfg(feature = "alloc")]
fn h(s: &str) -> Vec<u8> {
match test::from_hex(s) {
Ok(v) => v,
// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-use ring::{digest, test, test_file};
+use ring::{digest, test};
+
+#[cfg(feature = "alloc")]
+use ring::test_file;
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::{wasm_bindgen_test, wasm_bindgen_test_configure};
/// Test vectors from BoringSSL, Go, and other sources.
#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
+#[cfg(feature = "alloc")]
fn digest_misc() {
test::run(test_file!("digest_tests.txt"), |section, test_case| {
assert_eq!(section, "");
});
}
+#[cfg(feature = "alloc")]
mod digest_shavs {
use ring::{digest, test};
#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
+ #[cfg(feature = "alloc")]
fn short_msg_known_answer_test() {
run_known_answer_test(
&digest::$algorithm_name,
#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
+ #[cfg(feature = "alloc")]
fn long_msg_known_answer_test() {
run_known_answer_test(
&digest::$algorithm_name,
#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
+ #[cfg(feature = "alloc")]
fn monte_carlo_test() {
run_monte_carlo_test(
&digest::$algorithm_name,
use ring::{
rand,
signature::{self, KeyPair},
- test, test_file,
+ test,
};
+#[cfg(feature = "alloc")]
+use ring::test_file;
+
// ECDSA *signing* tests are in src/ec/ecdsa/signing.rs.
#[test]
+#[cfg(feature = "alloc")]
fn ecdsa_from_pkcs8_test() {
test::run(
test_file!("ecdsa_from_pkcs8_tests.txt"),
}
#[test]
+#[cfg(feature = "alloc")]
fn signature_ecdsa_verify_asn1_test() {
test::run(
test_file!("ecdsa_verify_asn1_tests.txt"),
}
#[test]
+#[cfg(feature = "alloc")]
fn signature_ecdsa_verify_fixed_test() {
test::run(
test_file!("ecdsa_verify_fixed_tests.txt"),
// signature verifies correctly. The known-answer tests themselves are in
// ecsda/signing.rs.
#[test]
+#[cfg(feature = "alloc")]
fn signature_ecdsa_sign_fixed_sign_and_verify_test() {
let rng = rand::SystemRandom::new();
// signature verifies correctly. The known-answer tests themselves are in
// ecsda/signing.rs.
#[test]
+#[cfg(feature = "alloc")]
fn signature_ecdsa_sign_asn1_test() {
let rng = rand::SystemRandom::new();
use ring::{
error,
signature::{self, Ed25519KeyPair, KeyPair},
- test, test_file,
+ test,
};
+#[cfg(feature = "alloc")]
+use ring::test_file;
+
/// Test vectors from BoringSSL.
#[test]
+#[cfg(feature = "alloc")]
fn test_signature_ed25519() {
test::run(test_file!("ed25519_tests.txt"), |section, test_case| {
assert_eq!(section, "");
}
#[test]
+#[cfg(feature = "alloc")]
fn test_ed25519_from_pkcs8_unchecked() {
// Just test that we can parse the input.
test::run(
}
#[test]
+#[cfg(feature = "alloc")]
fn test_ed25519_from_pkcs8() {
// Just test that we can parse the input.
test::run(
// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-use ring::{digest, error, hkdf, test, test_file};
+use ring::{digest, error, hkdf, test};
+
+#[cfg(feature = "alloc")]
+use ring::test_file;
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::{wasm_bindgen_test, wasm_bindgen_test_configure};
#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
+#[cfg(feature = "alloc")]
fn hkdf_tests() {
test::run(test_file!("hkdf_tests.txt"), |section, test_case| {
assert_eq!(section, "");
// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-use ring::{digest, error, hmac, test, test_file};
+use ring::{digest, error, hmac, test};
+
+#[cfg(feature = "alloc")]
+use ring::test_file;
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::{wasm_bindgen_test, wasm_bindgen_test_configure};
#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
+#[cfg(feature = "alloc")]
fn hmac_tests() {
test::run(test_file!("hmac_tests.txt"), |section, test_case| {
assert_eq!(section, "");
// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
use core::num::NonZeroU32;
-use ring::{digest, error, pbkdf2, test, test_file};
+use ring::{digest, error, pbkdf2, test};
+
+#[cfg(feature = "alloc")]
+use ring::test_file;
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::{wasm_bindgen_test, wasm_bindgen_test_configure};
/// Test vectors from BoringSSL, Go, and other sources.
#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
+#[cfg(feature = "alloc")]
pub fn pbkdf2_tests() {
test::run(test_file!("pbkdf2_tests.txt"), |section, test_case| {
assert_eq!(section, "");
// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-use ring::{aead::quic, test, test_file};
+use ring::{aead::quic, test};
+
+#[cfg(feature = "alloc")]
+use ring::test_file;
#[test]
+#[cfg(feature = "alloc")]
fn quic_aes_128() {
test_quic(&quic::AES_128, test_file!("quic_aes_128_tests.txt"));
}
#[test]
+#[cfg(feature = "alloc")]
fn quic_aes_256() {
test_quic(&quic::AES_256, test_file!("quic_aes_256_tests.txt"));
}
#[test]
+#[cfg(feature = "alloc")]
fn quic_chacha20() {
test_quic(&quic::CHACHA20, test_file!("quic_chacha20_tests.txt"));
}
+#[cfg(feature = "alloc")]
fn test_quic(alg: &'static quic::Algorithm, test_file: test::File) {
test_sample_len(alg);